package com.powernode.controller;

import com.powernode.model.Result;
import com.powernode.service.SendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 发送短信控制层
 */
@Api(tags = "短信发送接口管理")
@RequestMapping("p/sms")
@RestController
public class SendController {

    @Autowired
    private SendService sendService;

    @ApiOperation("发送短信验证码")
    @PostMapping("send")
    public Result<String> sendPhoneMsg(@RequestBody Map<String,Object> map) throws Exception {
        sendService.sendPhoneMsg(map);
        return Result.success("发送成功");
    }

//    p/sms/savePhone
    @ApiOperation("绑定手机号码")
    @PostMapping("savePhone")
    public Result<String> savePhone(@RequestBody Map<String,Object> map) {
        Boolean saved = sendService.savePhone(map);
        return Result.handle(saved);
    }
}
